MAKEPAL Weird Palindrome Making - CodeChef Solution


Implementation basic

Python Code:

t=int(input())
for _ in range(t):
    number=int(input())
    arr=list(map(int,input().split()))
    odd=0
    total=0
    for num in arr:
        if num%2!=0:
            odd+=1
        total+=num
    
    if number==1:print(0)
    elif number==2 and odd==1:print(0)
    elif total%2==0:
        print(odd//2)
    elif total%2!=0:
        print((odd-1)//2)


Comments

Submit
0 Comments
More Questions

Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game